<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix='sec' uri='http://www.springframework.org/security/tags'%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<title>订单中心</title>
	<script type="text/javascript" src="scripts/boot.js"></script>
    <style type="text/css">
	    html,body
	    {
	    	height:100%;
	    	margin:0;,padding:0;
	    }   
    </style>
</head>
<body>
	<div id="toolbar1" class="mini-toolbar" style="padding:2px;" align="right">
		<div class="toplogo"><img src="scripts/miniui/themes/default/images/layout/logo-dingdan.png" /></div>
		<a class="mini-button mini-button-iconTop" iconCls="icon-extension" plain="true" onclick="loginExtension" id="btn_lo_ex">登录分机</a>
		<a class="mini-button mini-button-iconTop" iconCls="icon-extension" plain="true" onclick="leave" id="btn_leave" visible="false">离席</a>
		<a class="mini-button mini-button-iconTop" iconCls="icon-outgoing" plain="true" onclick="outgoing" id="btn_outgoing" enabled="false">呼出</a>
		<a class="mini-button mini-button-iconTop" iconCls="icon-outgoing" plain="true" onclick="telHangUp" id="btn_hangup" visible="false">挂断</a>
        <a class="mini-button mini-button-iconTop" iconCls="icon-turn" plain="true" id="btn_blind_turn" onclick="blindTurn" enabled="false">忙转</a>
    	<a class="mini-button mini-button-iconTop" iconCls="icon-close" style="float: right;" onclick="logOut()" plain="true" >退出</a>
    
    </div>
    <input class="mini-hidden" id="queueNum" />
    <input class="mini-hidden" id="callerNum" />
    <!-- 绑定分机弹窗 -->
    <div id="win1" class="mini-window" allowDrag="false" showModal="false" showHeader="true" title="登录分机" style="width: 280px;height: 170px;">
    	<input class="mini-hidden" id="workId" value="<sec:authentication property='principal.username'/>" />
	    <input labelField="true" label="分机号：" labelStyle="width: 90px;" class="mini-textbox" style="width:200px;margin-top: 10px;margin-left: 15px;" id="extenNumId" required="true"/> 
<!-- 		<input labelField="true" label="选择队列：" labelStyle="width: 90px;" class="mini-combobox" style="width:200px;margin-top: 10px;margin-left: 15px;" id="queueNumId" textField="text" multiSelect="true" valueField="text" data="[{id: 9000, text: 9000},{id: 8000, text: 8000}]"/>  -->
		<input labelField="true" label="选择队列：" labelStyle="width: 90px;" class="mini-combobox" style="width:200px;margin-top: 10px;margin-left: 15px;" id="queueNumId" textField="queueNo" multiSelect="true" valueField="queueNo" url="alternately_find_queue.do"/> 
		<div style="text-align:center;padding-bottom: 10px;margin-top: 30px;">
			<a class="mini-button" onclick="loginExtensionOk" style="">确定</a>
			<a class="mini-button" onclick="onClose1" style="margin-left: 50px;">关闭</a>
		</div>
	</div>
	<!-- 呼出弹窗 -->
	<div id="win2" class="mini-window" allowDrag="false" showHeader="true" title="呼出" style="width: 280px;height: 150px;">
	    <input class="mini-hidden" id="callerNum" />
	    <input labelField="true" label="号码：" labelStyle="width: 90px;" class="mini-textbox" style="width:200px;margin-top: 10px;margin-left: 15px;" id="outNumId" required="true"/> 
	    <input labelField="true" label="加拨：" labelStyle="width: 90px;" class="mini-combobox" style="width:200px;margin-top: 10px;margin-left: 15px;" id="addNum"
	    	url="dictionary_cm_key_val_view.do?typeName=CALL_ADD_TYPE" textField="keyValue" valueField="keyValue" showNullItem="true" nullItemText="无"/> 
		<div style="text-align:center;padding-bottom: 10px;margin-top: 15px;">
			<a class="mini-button" onclick="outgoingOk" style="">确定</a>
			<a class="mini-button" onclick="onClose2" style="margin-left: 50px;">关闭</a>
		</div>
	</div>
	<!-- 盲转弹窗 -->
	<div id="win3" class="mini-window" allowDrag="false" showHeader="true" title="盲转" style="width: 280px;height: 140px;">
	    <input labelField="true" label="转接分机号：" labelStyle="width: 90px;" class="mini-textbox" style="width:200px;margin-top: 10px;margin-left: 15px;" id="blindTurnNum" /> 
		<div style="text-align:center;padding-bottom: 10px;margin-top: 30px;">
			<a class="mini-button" onclick="blindTurnOk" >确定</a>
			<a class="mini-button" onclick="onClose3" style="margin-left: 50px;">关闭</a>
		</div>
	</div>
    
    <div class="mini-fit">
    <div class="mini-splitter" style="width:100%;height:100%;" borderStyle="border-top:none;">
    
    <div size="15%" showCollapseButton="true">
	    <table cellpadding="0" cellspacing="0" style="height:100%;width:100%;table-layout:fixed">
	        <tr>
	            <td style="width:30px;height:100%;">
	                <div class="leftNav">
	                    <div style="padding-top:20px;">
	                        <sec:authorize url='/cm_sys_manger.do'>
	                        <a class="leftNav-cm" title="话务中心" href="${urlPath}/cm"></a>
	                        </sec:authorize>
	                        <sec:authorize url='/om_sys_manger.do'>
	                        <a class="leftNav-om selected" title="订单中心" href="${urlPath}/om"></a>
	                        </sec:authorize>
	                        <sec:authorize url='/wm_sys_manger.do'>
	                        <a class="leftNav-wm" title="仓储中心" href="${urlPath}/wm"></a>
	                        </sec:authorize>
	                        <sec:authorize url='/fm_sys_manger.do'>
	                        <a class="leftNav-fm" title="财务中心" href="${urlPath}/fm"></a>
	                        </sec:authorize>
	                        <sec:authorize url='/mm_sys_manger.do'>
	                        <a class="leftNav-mm" title="媒体中心" href="${urlPath}/mm"></a>
	                        </sec:authorize>
	                        <sec:authorize url='/ss_sys_manger.do'>
	                        <a class="leftNav-ss" title="统计中心" href="${urlPath}/ss"></a>
	                        </sec:authorize>
	                        <sec:authorize url='/hm_sys_manger.do'>
	                        <a class="leftNav-hm" title="人资中心" href="${urlPath}/hm"></a>
	                        </sec:authorize>
	                    </div>
	                </div>
	            </td>
	            <td style="height:100%;">
<!-- 	                <div id="outlookbar1" class="mini-outlookbar " activeIndex="0"  style="width:auto;height:100%;" autoCollapse="true"> -->
<!-- 				        <div title="订单分配" iconCls="icon-addfolder" headerStyle="font-size: medium;"> -->
<!-- 				           <div class="mini-menu-float" style="height: auto;"> -->
<!-- 								<div class="mini-menuitem"> -->
<!-- 									<div class="mini-menuitem-inner"> -->
<!-- 										<div class="mini-menuitem-icon icon-node" style="display: block;"></div> -->
<!-- 										<div class="mini-menuitem-text"><a class="mini-menuitem-text" href="javascript:showTab({id: 'allocation_tabs_init', text:'核单部订单分配', url:'allocation_tabs_init.do'});">核单部订单分配</a></div> -->
<!-- 										<div class="mini-menuitem-allow"></div> -->
<!-- 									</div> -->
<!-- 								</div> -->
<!-- 							</div> -->
<!-- 							<div class="mini-menu-float" style="height: auto;"> -->
<!-- 								<div class="mini-menuitem"> -->
<!-- 									<div class="mini-menuitem-inner"> -->
<!-- 										<div class="mini-menuitem-icon icon-node" style="display: block;"></div> -->
<!-- 										<div class="mini-menuitem-text"><a class="mini-menuitem-text" href="javascript:showTab({id: 'allocation_center_tabs_init', text:'中心订单分配', url:'allocation_center_tabs_init.do'});">中心订单分配</a></div> -->
<!-- 										<div class="mini-menuitem-allow"></div> -->
<!-- 									</div> -->
<!-- 								</div> -->
<!-- 							</div> -->
<!-- 							<div class="mini-menu-float" style="height: auto;"> -->
<!-- 								<div class="mini-menuitem"> -->
<!-- 									<div class="mini-menuitem-inner"> -->
<!-- 										<div class="mini-menuitem-icon icon-node" style="display: block;"></div> -->
<!-- 										<div class="mini-menuitem-text"><a class="mini-menuitem-text" href="javascript:showTab({id: 'allocation_group_tabs_init', text:'核单组订单分配', url:'allocation_group_tabs_init.do'});">核单组订单分配</a></div> -->
<!-- 										<div class="mini-menuitem-allow"></div> -->
<!-- 									</div> -->
<!-- 								</div> -->
<!-- 							</div> -->
<!-- 				        </div> -->
<!-- 				        <div title="订单审核" iconCls="icon-addfolder" headerStyle="font-size: medium;"> -->
<!-- 				            <div class="mini-menu-float" style="height: auto;"> -->
<!-- 								<div class="mini-menuitem"> -->
<!-- 									<div class="mini-menuitem-inner"> -->
<!-- 										<div class="mini-menuitem-icon icon-node" style="display: block;"></div> -->
<!-- 										<div class="mini-menuitem-text"><a class="mini-menuitem-text" href="javascript:showTab({id: 'audit_init', text:'待审核订单', url:'audit_init.do'});">待审核订单</a></div> -->
<!-- 										<div class="mini-menuitem-allow"></div> -->
<!-- 									</div> -->
<!-- 								</div> -->
<!-- 							</div> -->
<!-- 				            <div class="mini-menu-float" style="height: auto;"> -->
<!-- 								<div class="mini-menuitem"> -->
<!-- 									<div class="mini-menuitem-inner"> -->
<!-- 										<div class="mini-menuitem-icon icon-node" style="display: block;"></div> -->
<!-- 										<div class="mini-menuitem-text"><a class="mini-menuitem-text" href="javascript:showTab({id: 'platform_audit_init', text:'平台待审核订单', url:'platform_audit_init.do'});">中心待审核订单</a></div> -->
<!-- 										<div class="mini-menuitem-allow"></div> -->
<!-- 									</div> -->
<!-- 								</div> -->
<!-- 							</div> -->
<!-- 				            <div class="mini-menu-float" style="height: auto;"> -->
<!-- 								<div class="mini-menuitem"> -->
<!-- 									<div class="mini-menuitem-inner"> -->
<!-- 										<div class="mini-menuitem-icon icon-node" style="display: block;"></div> -->
<!-- 										<div class="mini-menuitem-text"><a class="mini-menuitem-text" href="javascript:showTab({id: 'group_audit_init', text:'本组待审核订单', url:'group_audit_init.do'});">本组待审核订单</a></div> -->
<!-- 										<div class="mini-menuitem-allow"></div> -->
<!-- 									</div> -->
<!-- 								</div> -->
<!-- 							</div> -->
<!-- 							<div class="mini-menu-float" style="height: auto;"> -->
<!-- 								<div class="mini-menuitem"> -->
<!-- 									<div class="mini-menuitem-inner"> -->
<!-- 										<div class="mini-menuitem-icon icon-node" style="display: block;"></div> -->
<!-- 										<div class="mini-menuitem-text"><a class="mini-menuitem-text" href="javascript:showTab({id: 'my_audit_init', text:'我的待审核订单', url:'my_audit_init.do'});">我的待审核订单</a></div> -->
<!-- 										<div class="mini-menuitem-allow"></div> -->
<!-- 									</div> -->
<!-- 								</div> -->
<!-- 							</div> -->
<!-- 				        </div> -->
<!-- 				        <div title="订单维护" iconCls="icon-addfolder" headerStyle="font-size: medium;"> -->
<!-- 				            <div class="mini-menu-float" style="height: auto;"> -->
<!-- 								<div class="mini-menuitem"> -->
<!-- 									<div class="mini-menuitem-inner"> -->
<!-- 										<div class="mini-menuitem-icon icon-node" style="display: block;"></div> -->
<!-- 										<div class="mini-menuitem-text"><a class="mini-menuitem-text" href="javascript:showTab({id: 'cancel_init', text:'订单取消', url:'cancel_init.do'});">订单取消</a></div> -->
<!-- 										<div class="mini-menuitem-allow"></div> -->
<!-- 									</div> -->
<!-- 								</div> -->
<!-- 							</div> -->
<!-- 				            <div class="mini-menu-float" style="height: auto;"> -->
<!-- 								<div class="mini-menuitem"> -->
<!-- 									<div class="mini-menuitem-inner"> -->
<!-- 										<div class="mini-menuitem-icon icon-node" style="display: block;"></div> -->
<!-- 										<div class="mini-menuitem-text"><a class="mini-menuitem-text" href="javascript:showTab({id: 'orders_find_init', text:'订单查询', url:'orders_find_init.do'});">订单查询</a></div> -->
<!-- 										<div class="mini-menuitem-allow"></div> -->
<!-- 									</div> -->
<!-- 								</div> -->
<!-- 							</div> -->
<!-- 				        </div> -->
<!-- 				        <div title="订单统计" iconCls="icon-addfolder" headerStyle="font-size: medium;"> -->
<!-- 				            <div class="mini-menu-float" style="height: auto;"> -->
<!-- 								<div class="mini-menuitem"> -->
<!-- 									<div class="mini-menuitem-inner"> -->
<!-- 										<div class="mini-menuitem-icon icon-node" style="display: block;"></div> -->
<!-- 										<div class="mini-menuitem-text"><a class="mini-menuitem-text" href="javascript:showTab({id: 'check_user_orders_sta_init', text:'核单员订单统计', url:'check_user_orders_sta_init.do'});">核单员订单统计</a></div> -->
<!-- 										<div class="mini-menuitem-allow"></div> -->
<!-- 									</div> -->
<!-- 								</div> -->
<!-- 							</div> -->
<!-- 				            <div class="mini-menu-float" style="height: auto;"> -->
<!-- 								<div class="mini-menuitem"> -->
<!-- 									<div class="mini-menuitem-inner"> -->
<!-- 										<div class="mini-menuitem-icon icon-node" style="display: block;"></div> -->
<!-- 										<div class="mini-menuitem-text"><a class="mini-menuitem-text" href="javascript:showTab({id: 'media_statistics_init', text:'媒体订单统计', url:'media_statistics_init.do'});">媒体订单统计</a></div> -->
<!-- 										<div class="mini-menuitem-allow"></div> -->
<!-- 									</div> -->
<!-- 								</div> -->
<!-- 							</div> -->
<!-- 				            <div class="mini-menu-float" style="height: auto;"> -->
<!-- 								<div class="mini-menuitem"> -->
<!-- 									<div class="mini-menuitem-inner"> -->
<!-- 										<div class="mini-menuitem-icon icon-node" style="display: block;"></div> -->
<!-- 										<div class="mini-menuitem-text"><a class="mini-menuitem-text" href="javascript:showTab({id: 'product_sales_statistics_init', text:'产品销售统计', url:'product_sales_statistics_init.do'});">产品销售统计</a></div> -->
<!-- 										<div class="mini-menuitem-allow"></div> -->
<!-- 									</div> -->
<!-- 								</div> -->
<!-- 							</div> -->
<!-- 				            <div class="mini-menu-float" style="height: auto;"> -->
<!-- 								<div class="mini-menuitem"> -->
<!-- 									<div class="mini-menuitem-inner"> -->
<!-- 										<div class="mini-menuitem-icon icon-node" style="display: block;"></div> -->
<!-- 										<div class="mini-menuitem-text"><a class="mini-menuitem-text" href="javascript:showTab({id: 'province_orders_sta_init', text:'各省订单统计', url:'province_orders_sta_init.do'});">各省订单统计</a></div> -->
<!-- 										<div class="mini-menuitem-allow"></div> -->
<!-- 									</div> -->
<!-- 								</div> -->
<!-- 							</div> -->
<!-- 				            <div class="mini-menu-float" style="height: auto;"> -->
<!-- 								<div class="mini-menuitem"> -->
<!-- 									<div class="mini-menuitem-inner"> -->
<!-- 										<div class="mini-menuitem-icon icon-node" style="display: block;"></div> -->
<!-- 										<div class="mini-menuitem-text"><a class="mini-menuitem-text" href="javascript:showTab({id: 'orders_ride_pin_sta_init', text:'订单搭销产品', url:'orders_ride_pin_sta_init.do'});">订单搭销产品</a></div> -->
<!-- 										<div class="mini-menuitem-allow"></div> -->
<!-- 									</div> -->
<!-- 								</div> -->
<!-- 							</div> -->
<!-- 				        </div> -->
<!-- 				        <div title="日报管理" iconCls="icon-addfolder" headerStyle="font-size: medium;"> -->
<!-- 				            <div class="mini-menu-float" style="height: auto;"> -->
<!-- 								<div class="mini-menuitem"> -->
<!-- 									<div class="mini-menuitem-inner"> -->
<!-- 										<div class="mini-menuitem-icon icon-node" style="display: block;"></div> -->
<!-- 										<div class="mini-menuitem-text"><a class="mini-menuitem-text" href="javascript:showTab({id: 'init_order_group_sta_list', text:'本组订单统计', url:'init_order_group_sta_list.do'});">本组订单统计</a></div> -->
<!-- 										<div class="mini-menuitem-allow"></div> -->
<!-- 									</div> -->
<!-- 								</div> -->
<!-- 							</div> -->
<!-- 				            <div class="mini-menu-float" style="height: auto;"> -->
<!-- 								<div class="mini-menuitem"> -->
<!-- 									<div class="mini-menuitem-inner"> -->
<!-- 										<div class="mini-menuitem-icon icon-node" style="display: block;"></div> -->
<!-- 										<div class="mini-menuitem-text"><a class="mini-menuitem-text" href="javascript:showTab({id: 'init_order_center_sta_list', text:'中心订单统计', url:'init_order_center_sta_list.do'});">中心订单统计</a></div> -->
<!-- 										<div class="mini-menuitem-allow"></div> -->
<!-- 									</div> -->
<!-- 								</div> -->
<!-- 							</div> -->
<!-- 				        </div> -->
<!-- 				        <div title="系统管理" iconCls="icon-addfolder" headerStyle="font-size: medium;"> -->
<!-- 				        	<div class="mini-menu-float" style="height: auto;"> -->
<!-- 								<div class="mini-menuitem"> -->
<!-- 									<div class="mini-menuitem-inner"> -->
<!-- 										<div class="mini-menuitem-icon icon-node" style="display: block;"></div> -->
<!-- 										<div class="mini-menuitem-text"><a class="mini-menuitem-text" href="javascript:showTab({id: 'dictionary_init', text:'数据字典管理', url:'dictionary_init.do'});">数据字典管理</a></div> -->
<!-- 										<div class="mini-menuitem-allow"></div> -->
<!-- 									</div> -->
<!-- 								</div> -->
<!-- 							</div> -->
<!-- 				        </div> -->
<!-- 	    			</div> -->
					<div class="mini-outlookmenu" style="height:100%;width:100%;" expandOnLoad="false" borderStyle="border:0;border-left:1px solid #95bae7" idField="id" parentField="pid" textField="text" url="loadMenu.do" onitemclick="itemclick">
                   	</div>
	            </td>
	        </tr>
	    </table>
    </div>
    <div style="background:#ececec;">
        <!--Tabs-->
        <div id="mainTabs" class="mini-tabs bg-toolbar" contextMenu="#tabsMenu" activeIndex="0" style="width:100%;height:100%;" bodyStyle="border:0;background:white;">        
            <div name="first" title="首页" url="" style="width:100%;height:100%;">
            	
            </div>
        </div> 
        <ul id="tabsMenu" class="mini-contextmenu" onbeforeopen="onBeforeOpen">        
	        <li onclick="refreshTab">刷新标签页</li>                
	        <li onclick="closeTab">关闭标签页</li>                
		    <li onclick="closeAll">关闭所有标签页</li>
	        <li onclick="closeAllButFirst">关闭其他标签页</li>
    	</ul>
    </div>
    </div>
    </div>
    
    <div title="south" region="south" showSplit="false" showHeader="false" height="30" >
        <div style="line-height:28px;text-align:center;">Copyright ©北京傲天飞宏科技有限公司</div>
    </div>
    
<script type="text/javascript">

	mini.parse();
	// 全局变量（判断是退出还是离席）
	var logOutFlag = false;
	
    var tabs = mini.get("mainTabs");
	function showTab(node) {
	    var id = "tab$" + node.id;
	    var tab = tabs.getTab(id);
	    if (!tab) {
	        tab = {};
	        tab.name = id;
	        tab.title = node.text;
	        tab.showCloseButton = true;
	        tab.url = node.url;
	
	        tabs.addTab(tab);
	    } else {
	    	tabs.reloadTab(tab);
	    }
	    tabs.activeTab(tab);
	}       

    var currentTab = null;

    function onBeforeOpen(e) {
        currentTab = tabs.getTabByEvent(e.htmlEvent);
        if (!currentTab) {
            e.cancel = true;                
        }
    }

    ///////////////////////////
    
    function refreshTab() {
    	tabs.reloadTab(currentTab);
    }
    
    function closeTab() {
    	if(currentTab.name != 'first'){
    		tabs.removeTab(currentTab);
    	}
    }
    
    function closeAll() {
    	tabs.removeAll(tabs.getTab("first"));
    }
    
    function closeAllButFirst() {
    	var but = [currentTab];            
        but.push(tabs.getTab("first"));
        tabs.removeAll(but);
    }
    function itemclick(e) {
		showTab({id: e.item.id, text: e.item.text, url: e.item.url});
	}
    
/*连接WebSocket*/
    jQuery.openWebSocket("ws://172.16.2.11:8080/websocket");
    
/*连接成功时执行*/    
    function webSocketOnOpen(event) {
    	console.info("连接成功");
    	$.post("alternately_find_ext_queue.do", function(data) {
    		if(data.success) {
    			jQuery.bindExtenNumAndWeb(data.extension, workId.getValue());
    			var queueNums = data.queue.split(",");
    			
    			for(var i=0; i<queueNums.length; i++) {
    				jQuery.queueAdd(queueNums[i], data.extension);
    		    }
    			extenNumId.setValue(data.extension);
    			callerNum.setValue(data.extension);
    			queueNum.setValue(data.queue);
//     			sextension.setValue(data.extension);
//     			squeue.setValue(data.queue);
    		}
    	}, "json");
    }
    
/*接收软交换返回数据*/
    function webSocketOnMessage(event) {
    	var data = $.evalJSON(event.data);
    	console.info(data);
    	switch (data.Event) {
    	case "BindExtenNumAndWeb":
    		win1.hide();
			btnLoEx.hide();
			btnLeave.show();
			btnOutgoing.setEnabled(true);
			btnBlindTurn.setEnabled(true);
			extenNumId.setValue("");
    		break;
    	case "QueueMemberAdd":
    		$.post("alternately_login_ext.do", {userName: workId.getValue(), extension: callerNum.getValue(), queue: queueNum.getValue()}, function(data) {
   	 			if(data.success) {
	    			mini.showMessageBox({
		                title: "登录分机队列成功",
		                showModal:false,
		                iconCls: "mini-messagebox-info",
		                message: "成功加入" + queueNumId.getValue() + "队列",
		                timeout: 3000,
		                x: 'right',
		                y: 'bottom',
		            });
   	 			}
   	 		}, "json");
    		break;
    	case "UnBindExtenNumAndWeb":
    		$.post("alternately_loginout_ext.do", {userName: workId.getValue(), extension: callerNum.getValue()}, function(data) {
   	 			if(data.success) {
   	 				if(logOutFlag) {
   	 					location.href="j_spring_cas_security_logout";
   	 				} else {
			   	 		btnLoEx.show();
		    			btnLeave.hide();
		    			btnOutgoing.setEnabled(false);
		    			btnBlindTurn.setEnabled(false);
	// 	    			sextension.setValue("");
	// 	    			squeue.setValue("");
   	 				}
   	 			} 
   	 		}, "json");
    		break;
    	case "HangUp":
    		btnOutgoing.setEnabled(true);
    		btnHangup.hide();
    		btnLeave.setEnabled(true);
    		break;
    	}
    	
    }
    
 // 登录分机弹窗
 	var callerNum = mini.get("callerNum");				// 解除绑定、呼出、盲转主叫号码
    var win1 = mini.get("win1");
    var btnLoEx = mini.get("btn_lo_ex");				// 绑定分机按钮
    var btnLeave = mini.get("btn_leave");				// 解除绑定按钮
    var queueNum = mini.get("queueNum");				// 登录分机后的队列
    var form1 = new mini.Form("win1");
    var el = btnLoEx.getEl();
    win1.showAtEl(el, {
	   xAlign:"left",
	   yAlign:"below"
	});
    function loginExtension() {
    	win1.showAtEl(el, {
		   xAlign:"left",
		   yAlign:"below"
		});
    }
    
    function onClose1(){
		win1.hide();
	}
    
    // 确定登录
    var extenNumId = mini.get("extenNumId");			// 分机号
    var workId = mini.get("workId");					// 工号
    var queueNumId = mini.get("queueNumId");			// 登录分机输入的队列
    function loginExtensionOk() {
	    form1.validate();
	    if (form1.isValid() == false) return;
	    jQuery.bindExtenNumAndWeb(extenNumId.getValue(), workId.getValue());
	    var queues = queueNumId.getValue().split(",");
	    for(var i=0; i<queues.length; i++) {
			jQuery.queueAdd(queues[i], extenNumId.getValue());
	    }
		jQuery.pingWebSocket(extenNumId.getValue());		// 心跳检测
		
		// 设置分机号、队列号变量离席时使用
		callerNum.setValue(extenNumId.getValue());
		queueNum.setValue(queueNumId.getValue());
// 		extenNumId.setValue("");
// 		queueNumId.setValue("");
	}

	/**
	 * 解除绑定(话务员离席)
	 * extenNum  分机号
	 */
	function leave() {
		var queueNums = queueNum.getValue().split(",");
		console.info(queueNums);
		for(var i=0; i<queueNums.length; i++) {
			jQuery.unBindExtenNumAndWeb(callerNum.getValue(), queueNums[i]);	// 无法将分机从队列移除。
			jQuery.queueRemove(queueNums[i], callerNum.getValue());				// 删除队列成员
		}
	}
	
	
	// 呼出弹窗
    var win2 = mini.get("win2");
    var form2 = new mini.Form("win2");
    function outgoing(e) {
    	var el=e.sender.getEl();
    	win2.showAtEl(el, {
		   xAlign:"left",
		   yAlign:"below"
		});
    }
    
    function onClose2() {
    	win2.hide();
    }
    
	/**
	 *	呼叫
	 * extenNum 主叫号码
	 * callNum  被叫号码 
	 */
	var addNum = mini.get("addNum");		// 加拨号码
	var outNumId = mini.get("outNumId");	// 外线号码
	var btnOutgoing = mini.get("btn_outgoing"); // 呼出按钮
	function outgoingOk() {
		var arr = new Array;
	    form2.validate();
	    if (form2.isValid() == false) return;
		arr[0] = addNum.getValue();
		arr[1] = outNumId.getValue();
		var callNum = arr.join("");
		jQuery.dail(callerNum.getValue(), callNum);
		win2.hide();
		btnOutgoing.setEnabled(false);
		btnHangup.show();
		btnLeave.setEnabled(false);
	}
	
	/**
	  * 挂断 
	  * extenNum 分机号码 
	  */
	var btnHangup = mini.get("btn_hangup");
	function telHangUp() {
		jQuery.hangUp(callerNum.getValue());
	}
	
	 // 盲转弹窗
    var win3 = mini.get("win3");
	var btnBlindTurn = mini.get("btn_blind_turn");
    function blindTurn(e) {
    	var el=e.sender.getEl();
    	win3.showAtEl(el, {
		   xAlign:"left",
		   yAlign:"below"
		});
    }
    
    function onClose3(){
		win3.hide();
	}
    
    var blindTurnNum = mini.get("blindTurnNum");
    function blindTurnOk() {
    	jQuery.redirect(callerNum.getValue(), blindTurnNum.getValue());
    	blindTurnNum.setValue("");
		win3.hide();
    }
    
 // 退出登录
	function logOut() {
		if(callerNum.getValue().length > 0 && queueNum.getValue().length > 0) {
			logOutFlag = true;
			leave();
		} else {
			location.href="j_spring_cas_security_logout";
		}
	}
    
</script>
</body>
</html>